package service

import (
	"ChinaDistrictCrawler/internal/model/entity"
	"ChinaDistrictCrawler/internal/service/internal/dao"
	"context"
)

type sStreet struct{}

var insStreet = sStreet{}

func Street() *sStreet {
	return &insStreet
}

// Create 创建内容
func (s *sStreet) Create(ctx context.Context, in entity.Street) (int, error) {
	_, err := dao.Street.Ctx(ctx).Data(in).InsertAndGetId()
	if err != nil {
		return 0, err
	}
	return 1, nil
}

func (s *sStreet) Info(ctx context.Context, id uint) (entity.Street, error) {
	var result entity.Street
	err := dao.Street.Ctx(ctx).WherePri(id).Scan(&result)
	if err != nil {
		return result, err
	}
	return result, nil
}
